package com.example.demo.service.impl;

import com.example.demo.mapper.RoleMapper;
import com.example.demo.pojo.RoleEntity;
import com.example.demo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<RoleEntity> getRolePage() {
//    int offset = (page - 1) * size;
    return roleMapper.getRolePage(); // 使用 MyBatis 的分页查询
}

    @Override
    public int getRoleCount() {
        return roleMapper.getRoleCount();
    }

    @Override
    public List<RoleEntity> getAllRoles() {
        return roleMapper.getAllRoles();
    }

    @Override
    public RoleEntity addRole(RoleEntity role) {
        roleMapper.addRole(role);
        return role;
    }

    @Override
    public RoleEntity updateRole(RoleEntity role) {
        roleMapper.updateRole(role);
        return role;
    }

    @Override
    public void deleteRole(String name) {
        roleMapper.deleteRole(name);
    }

    @Override
    public RoleEntity getRoleById(Long id) {
        return roleMapper.getRoleById(id);
    }

    @Override
    public Void updateRoleMnue(RoleEntity role) {
        roleMapper.updateRoleMnue(role);
        return null;
    }
}
